package com.norbitltd.guavaleaves.java.lang;

import com.google.common.base.Predicate;

public class FloatPredicates {
	
	/**
	 * Returns a predicate which checks whether the predicate argument is
	 * greater than a given float value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is greater than f, false otherwise
	 */
	public static Predicate<Float> isGreaterThan(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input > f;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is
	 * greater than or equal to a given float value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is greater than or equal to f, false
	 *         otherwise
	 */
	public static Predicate<Float> isGreaterOrEqualThan(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input >= f;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower
	 * than a given float value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is lower than f, false otherwise
	 */
	public static Predicate<Float> isLowerThan(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input < f;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower
	 * that or equal to than a given float value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is lower than or equal to f, false
	 *         otherwise
	 */
	public static Predicate<Float> isLowerOrEqualThan(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input <= f;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is equal
	 * to a given int value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is equal to f, false otherwise
	 */
	public static Predicate<Float> isEqual(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input == f;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is not
	 * equal to a given int value
	 * 
	 * @param f
	 *            Value to compare the predicate value with
	 * @return True if the predicate value is not equal to f, false otherwise
	 */
	public static Predicate<Float> isNotEqual(final float f) {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input != f;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a
	 * positive int value
	 * 
	 * @return True if the predicate value is greater than 0, false otherwise
	 */
	public static Predicate<Float> isPositive() {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input > 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a
	 * negative int value
	 * 
	 * @return True if the predicate value is lower than 0, false otherwise
	 */
	public static Predicate<Float> isNegative() {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input < 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a
	 * zero-valued int value
	 * 
	 * @return True if the predicate value is equal 0, false otherwise
	 */
	public static Predicate<Float> isZero() {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input == 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is not a
	 * zero-valued int value
	 * 
	 * @return True if the predicate value is not equal 0, false otherwise
	 */
	public static Predicate<Float> isNotZero() {
		return new Predicate<Float>() {
			public boolean apply(Float input) {
				return input != null && input != 0;
			}
		};
	}
}
